package Java_Test;

import java.util.Scanner;

public class JavaEx_Fan {
	
	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		FanVO3 fv = new FanVO3();
		boolean b = true;
		
		do {
			System.out.print("선풍기 회전 속도를 입력하시오(0 ~ 3) : ");
			fv.setSpeed(sc.nextInt());
			if(fv.getSpeed() > 3 || fv.getSpeed() < 0) {
				System.out.println("잘못입력하셨습니다. 다시 입력하세요");
			} else if(fv.getSpeed() == 0) {
				FanService3.showFanInfo(false); fv.setOn(false); break;
			} else {
				FanService3.showFanInfo(true); fv.setOn(true); break;
			}
		} while(b);
		
		System.out.print("선풍기 팬의 크기를 입력하시오 : ");
		fv.setRadius(sc.nextFloat());
		sc = new Scanner(System.in);
		System.out.print("선풍기 색상을 입력하시오 : ");
		fv.setColor(sc.next());
		
		System.out.println(fv.toString());
	}
}

class FanVO3 {
	private final int SLOW = 1;
	private final int MEDIUM = 2;
	private final int FAST = 3;
	private int speed;
	private boolean on;
	private float radius;
	private String color;
	
	public FanVO3() {
		speed = SLOW;
		on = false;
		radius = 5.0f;
		color = "blue";
	}
	public FanVO3(int speed, boolean on, float radius, String color) {
		this.speed = speed;
		this.on = on;
		this.radius = radius;
		this.color = color;
	}
	
	public void setSpeed(int speed) { this.speed = speed; }
	public void setOn(boolean on) { this.on = on; }
	public void setRadius(float radius) { this.radius = radius; }
	public void setColor(String color) { this.color = color; }
	public int getSpeed() { return speed; }
	public boolean getOn() { return on; }
	public float getRadius() { return radius; }
	public String getColor() { return color; }
	
	@Override
	public String toString() {
		StringBuilder sb = new StringBuilder();
		sb.append("○입력하신 내용에 대한 결과값입니다.○").append("\n○ 선풍기 팬의 크기 : ").append(getRadius())
		.append("\n○ 선풍기 색상 : ").append(getColor()).append("\n○ 선풍기 작동여부 : ")
		.append(FanService3.showFanInfo(getOn()));
		if(getOn()) {
			sb.append("\n○ 선풍기 회전 속도 : ").append(getSpeed());
		}
		return sb.toString();
	}
}

class FanService3 {
	static String showFanInfo(boolean on) {
		if(on) { return "동작중"; }
		else { return "꺼져있음"; }
	}
}